package com.decent.ejfadmin.finance.service;


import com.decent.ejfadmin.common.bean.*;
import com.decent.ejfadmin.common.enums.WithdrawLogTypeEnum;
import com.decent.ejfadmin.common.exception.SupException;
import com.decent.ejfadmin.finance.request.RebateUserQueryParam;
import com.decent.ejfadmin.finance.request.WithdrawRecordQueryParam;
import com.decent.ejfadmin.finance.response.dto.WithdrawRecordDto;

import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;

/**
 * 供货系统资金管理
 *
 * @author 王元鑫
 * @date 2016/8/6
 */
public interface SupplyFinanceService {
    /**
     * 修改供货余额、供货明细
     *
     * @param supplyConsumption 资金明细
     * @return 当前余额（修改前）
     */
    BigDecimal modifyBalanceConsumption(SupplyConsumption supplyConsumption);

    /**
     * 查询供货余额
     *
     * @param userId 会员ID
     * @return SupplyBalance
     */
    SupplyBalance querySupplyBalanceVersion(Long userId);

    /**
     * 查询提现记录分页数据
     *
     * @param param
     * @return
     */
    Page findWithdrawRecordPage(WithdrawRecordQueryParam param);

    /**
     * 审核提现记录
     *
     * @param recordId   提现记录订单号
     * @param auditstate 审核状态
     * @throws Exception
     */
    MessageBean checkWithdrawRecord(Long recordId, Integer auditstate) throws Exception;

    /**
     * 再次转账
     *
     * @param recordId 提现记录订单号
     * @throws Exception
     */
    void resetTransfer(Long recordId) throws Exception;

    /**
     * 处理失败
     *
     * @param recordId
     * @throws Exception
     */
    void dealFail(Long recordId) throws Exception;

    /**
     * 自动审核是否开启
     *
     * @param status
     * @throws SupException
     */
    void changeAutoAuditStatus(Integer status) throws SupException;

    /**
     * 查询返利用户信息统计分页数据
     *
     * @param param
     * @return
     */
    Page findRebateUserPage(RebateUserQueryParam param);

    /**
     * 自动审核获取状态
     *
     * @return
     */
    boolean getAutoAuditStatus();

    /**
     * 分页查询供货日报表
     *
     * @param pageUnit    分页组件
     * @param startTime   查询开始时间
     * @param endTime     查询结束时间
     * @param userAccount 会员编号
     * @return list
     */
    Page querySupplyDailySheetPage(Page pageUnit, String startTime, String endTime, String userAccount);

    /**
     * 供货日报表导出
     *
     * @param startTime   查询开始时间
     * @param endTime     查询结束时间
     * @param userAccount 会员编号
     * @return
     */
    void downLoad(String startTime, String endTime, String userAccount, HttpServletResponse response);

    /**
     * 会员提现记录导出
     *
     * @param param
     * @return
     */
    void withdrawRecordDownLoad(WithdrawRecordQueryParam param, HttpServletResponse response);

    /**
     * 对异常、申请中状态的申请人工更改其状态
     *
     * @param withdrawRecord 提现类
     * @param oldState       页面订单提现状态
     * @return
     */
    MessageBean updateWithdrawState(WithdrawRecord withdrawRecord, Integer oldState) throws Exception;

    /**
     * 停止/开启自动开启自动审核获取状态
     *
     * @param status 0:启动  1:停止
     * @return
     */
    MessageBean stopOpenAutoAudit(Integer status);

    /**
     * 停止自动开启自动审核获取状态
     *
     * @return
     */
    boolean getStopOpenAutoAudit();

    /**
     * 查询提现记录操作日志
     *
     * @param withdrawId
     * @param type
     * @return
     */
    List<WithdrawLog> queryWithdrawLog(Long withdrawId, WithdrawLogTypeEnum type);

    /**
     * 查询会员提现明细
     *
     * @param param 查询参数
     * @return
     */
    List<WithdrawRecordDto> findWithdrawRecord(WithdrawRecordQueryParam param);
}
